(function () {
  'use strict';

  const { appId, menuId } = getAppIdAndMenuId();
  function getAppIdAndMenuId() {
    // 获取当前URL
    const currentUrl = window.location.href;
    // 解析URL
    const url = new URL(currentUrl);
    // 解析hash部分: #/home/app/c76ef194385e11eb9f43c90043244155?menuId=a2e9f2a035f611eba12e05f7f2349621
    const [hashPath, params] = url.hash.split('?');
    // 提取appId
    const appId = hashPath.split('/')[3];
    // 提取menuId参数
    const menuId = new URLSearchParams(params).get('menuId'); // "11ed6b1b9420f420bd7ceb5eb09eddb4"
    // 返回结果
    return { appId, menuId };
  }



  function tip(title, msg) {
    const htmlText = msg.replace(/\r?\n/g, '<br/>').replace(/[ ]/g, '&nbsp;');;
    // 创建弹窗元素
    let dialog = document.createElement('div');
    dialog.style.position = 'fixed';
    dialog.style.top = '50px';
    dialog.style.left = '50%';
    dialog.style.transform = 'translateX(-50%)';
    dialog.style.width = '800px';
    dialog.style.overflow = 'auto';
    dialog.style.background = '#fff';
    dialog.style.border = '1px solid #aaa';
    dialog.style.borderRadius = '8px';
    dialog.style.boxShadow = '0 4px 12px rgba(0,0,0,0.2)';
    dialog.style.zIndex = '99999';
    dialog.style.padding = '20px';
    dialog.style.fontFamily = 'sans-serif';
    dialog.style.textAlign = 'left';

    dialog.innerHTML = `
      <div style="display: flex;justify-content: space-between;align-items: center;padding-bottom: 10px;border-bottom: 1px solid #eee;margin-bottom: 15px;">
          <h3 style="font-size: 18px;font-weight: bold;margin: 0;">${title}</h3>
          <button style="font-size: 24px;font-weight: bold;cursor: pointer;padding: 0 5px;border: none;">&times;</button>
      </div>
      <div style="overflow: auto;margin-bottom: 15px;height: 800px;">${htmlText}</div>
    `;

    dialog.querySelector('button').addEventListener('click', () => {
      dialog.remove();
    });

    document.body.appendChild(dialog);
  }

  // 获取特定名称的Cookie值
  function getCookie(name) {
    const value = `; ${document.cookie}`;
    const parts = value.split(`; ${name}=`);
    if (parts.length === 2) return parts.pop().split(';').shift();
  }

})();